package DiErZhou.Day1;

import java.util.Scanner;

public class Day1_10 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个N位整数");
        int num= scanner.nextInt();
        int acopy=num;
        int len=0;
        while (num!=0){
            num=num/10;
            len++;
        }
        int r=1;
        for (int i=1;i<=len-1;i++){
            r=r*10;
        }
        int acopy1=acopy%r;
        int sum=0;
        while (acopy1!=0){
            sum+=acopy1%10;
            acopy1/=10;
        }
        System.out.println("sum = " + sum);

    }
}
